Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cm/ol crowding accuracy logging #1862

Merged
merged 12 commits into from
Sep 18, 2023
Merged

Conversation

cmaddox5
Copy link
Contributor

@cmaddox5 cmaddox5 commented Sep 14, 2023

Asana task: Add logging to triptych app - pt 1 1/2

During the heuristics discussion, we realized we aren't able to capture crowding widget accuracy while the widget is on screen. In this PR, I added a DynamicSupervisor that is able to spin up background processes that log crowding data every 5 seconds until the train is stopped at the current station. With these logs, we will be able to compare the existing logs ([train_crowding car_crowding_info]) with the added logs ([train_crowding car_crowding_accuracy_info]). If the car_crowding_levels change at all, we know that we were not able to give accurate crowding data to riders before the train arrived.

I did make one change to the widget logic. I moved the crowding class translations up to the vehicle parser. This allows us to see if a crowding class change results in a color change on screen.

  • Tests added?

@github-actions
Copy link

Coverage of commit 8533aa1

Summary coverage rate:
  lines......: 40.5% (2289 of 5645 lines)
  functions..: 42.1% (1051 of 2497 functions)
  branches...: no data found

Files changed coverage rate:
                                                                           |Lines       |Functions  |Branches    
  Filename                                                                 |Rate     Num|Rate    Num|Rate     Num
  ===============================================================================================================
  lib/screens/application.ex                                               |75.0%      4|50.0%     2|    -      0
  lib/screens/ol_crowding/logger.ex                                        | 0.0%     15| 0.0%     4|    -      0
  lib/screens/ol_crowding/supervisor.ex                                    |50.0%      4|66.7%     3|    -      0
  lib/screens/v2/candidate_generator/widgets/train_crowding.ex             |70.6%     34|55.6%     9|    -      0
  lib/screens/v2/widget_instance/train_crowding.ex                         |61.5%     26|92.9%    14|    -      0
  lib/screens/vehicles/parser.ex                                           | 0.0%     29| 0.0%     9|    -      0

Download coverage report

@github-actions
Copy link

Coverage of commit f58bd4f

Summary coverage rate:
  lines......: 40.5% (2289 of 5654 lines)
  functions..: 42.0% (1051 of 2502 functions)
  branches...: no data found

Files changed coverage rate:
                                                                           |Lines       |Functions  |Branches    
  Filename                                                                 |Rate     Num|Rate    Num|Rate     Num
  ===============================================================================================================
  lib/screens/application.ex                                               |75.0%      4|50.0%     2|    -      0
  lib/screens/ol_crowding/logger.ex                                        | 0.0%     16| 0.0%     4|    -      0
  lib/screens/ol_crowding/supervisor.ex                                    |50.0%      4|66.7%     3|    -      0
  lib/screens/v2/candidate_generator/widgets/train_crowding.ex             |70.6%     34|55.6%     9|    -      0
  lib/screens/v2/widget_instance/train_crowding.ex                         |61.5%     26|92.9%    14|    -      0
  lib/screens/vehicles/parser.ex                                           | 0.0%     29| 0.0%     9|    -      0

Download coverage report

Copy link
Member

@jzimbel-mbta jzimbel-mbta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a handful of things, mostly sanity checking.

The only thing I'm really concerned about is the lack of :restart opt on the start_child call. Assuming I interpreted the docs correctly (I definitely might not have!), the default :restart behavior will cause the supervisor to indefinitely restart any genserver that it spawns, even if the genserver shuts itself down with {:stop, :shutdown, state}. Which would cause an ever-increasing number of processes! 😱

lib/screens/ol_crowding/supervisor.ex Outdated Show resolved Hide resolved
lib/screens/ol_crowding/supervisor.ex Outdated Show resolved Hide resolved
Comment on lines 81 to 88
defp parse_carriage_occupancy_status("NO_DATA_AVAILABLE"), do: :no_data
defp parse_carriage_occupancy_status("MANY_SEATS_AVAILABLE"), do: :not_crowded
defp parse_carriage_occupancy_status("FEW_SEATS_AVAILABLE"), do: :not_crowded
defp parse_carriage_occupancy_status("STANDING_ROOM_ONLY"), do: :some_crowding
defp parse_carriage_occupancy_status("CRUSHED_STANDING_ROOM_ONLY"), do: :crowded
defp parse_carriage_occupancy_status("FULL"), do: :crowded
defp parse_carriage_occupancy_status("NOT_ACCEPTING_PASSENGERS"), do: :closed
defp parse_carriage_occupancy_status(_), do: nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little unusual to push this app-specific business logic all the way down to the parser, but I guess as long as we're sure we want to do this mapping from the v3 API's classification groups to our own in all cases, it's better to put here for consistency.

Could you also update the struct typespec in Screens.Vehicles.Vehicle to reflect that the carriage-level occupancy status values are now different from the vehicle-level occupancy statuses?

(This also makes me wonder if we should make this same change to parse_occupancy_status, for consistency. It feels weird to keep the v3 API's classifications for one but not the other.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have been too impulsive of a change, cause you're right. This does feel weird. Would it be better to add this conversion as a util function instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A util function could be good, yeah! Reusable but also doesn't force this mapping from v3 API classification to our classification in all cases.

lib/screens/ol_crowding/logger.ex Show resolved Hide resolved
lib/screens/ol_crowding/logger.ex Show resolved Hide resolved
@cmaddox5 cmaddox5 assigned jzimbel-mbta and unassigned cmaddox5 Sep 18, 2023
@github-actions
Copy link

Coverage of commit 9c9dd32

Summary coverage rate:
  lines......: 40.5% (2289 of 5654 lines)
  functions..: 42.0% (1051 of 2502 functions)
  branches...: no data found

Files changed coverage rate:
                                                                           |Lines       |Functions  |Branches    
  Filename                                                                 |Rate     Num|Rate    Num|Rate     Num
  ===============================================================================================================
  lib/screens/application.ex                                               |75.0%      4|50.0%     2|    -      0
  lib/screens/ol_crowding/dynamic_supervisor.ex                            |50.0%      4|66.7%     3|    -      0
  lib/screens/ol_crowding/logger.ex                                        | 0.0%     16| 0.0%     4|    -      0
  lib/screens/v2/candidate_generator/widgets/train_crowding.ex             |70.6%     34|55.6%     9|    -      0
  lib/screens/v2/widget_instance/train_crowding.ex                         |61.5%     26|92.9%    14|    -      0
  lib/screens/vehicles/parser.ex                                           | 0.0%     29| 0.0%     9|    -      0

Download coverage report

@cmaddox5 cmaddox5 merged commit 5a8d322 into master Sep 18, 2023
2 checks passed
@cmaddox5 cmaddox5 deleted the cm/ol-crowding-accuracy-logging branch September 18, 2023 14:22
@github-actions
Copy link

Coverage of commit 81b2576

Summary coverage rate:
  lines......: 40.6% (2296 of 5656 lines)
  functions..: 42.0% (1052 of 2502 functions)
  branches...: no data found

Files changed coverage rate:
                                                                           |Lines       |Functions  |Branches    
  Filename                                                                 |Rate     Num|Rate    Num|Rate     Num
  ===============================================================================================================
  lib/screens/application.ex                                               |75.0%      4|50.0%     2|    -      0
  lib/screens/ol_crowding/dynamic_supervisor.ex                            |50.0%      4|66.7%     3|    -      0
  lib/screens/ol_crowding/logger.ex                                        | 0.0%     16| 0.0%     4|    -      0
  lib/screens/util.ex                                                      |67.6%     68|76.5%    17|    -      0
  lib/screens/v2/candidate_generator/widgets/train_crowding.ex             |66.7%     36|55.6%     9|    -      0
  lib/screens/v2/widget_instance/train_crowding.ex                         |61.5%     26|92.9%    14|    -      0

Download coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants